package StructuralPattern.Proxy.StaticForceProxy;

/**
 * @Classname : GamePlayerProxy
 * @Description : 代理角色
 * @Author : chentianyu
 * @Date 2023/2/11 22:49
 */


public class GamePlayerProxy implements GamePlayer {

    private GamePlayer gamePlayer;

    public GamePlayerProxy(GamePlayer gamePlayer) {
        this.gamePlayer = gamePlayer;
    }

    @Override
    public void login() {
        this.gamePlayer.login();
    }

    @Override
    public void killBoss() {
        this.gamePlayer.killBoss();
    }

    @Override
    public void upgrade() {
        before();
        this.gamePlayer.upgrade();
        after();
    }

    @Override
    public GamePlayer getProxy() {
        return this;  // 代理角色没有代理角色，直接返回自己
    }

    private void before() {

    }

    private void after() {
        charge();
    }

    private void charge() {
        System.out.println("每升一级计费100元。");
    }
}
